//index.js
//获取应用实例
const app = getApp()
var utils = require('../../utils/utils.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperCurrent: 0,
  },
  //轮播图改变事件
  swiperChange: function(e){
    //console.log(e.detail.current);
    this.setData({
     swiperCurrent: e.detail.current
    })
   },

  bf: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id);
    console.log('---------------------');
    wx.navigateTo({
      url: '/pages/player/player?id='+ id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    utils.myRequest({
      url:'http://127.0.0.1:8000/',
      methods:'GET',
      success:function(res){
        console.log(res);//打印出返回的数据
        that.setData({
          showitem: true,
          result: res.data
        })
      },
      fail: function () {
        that.setData({
          showitem: false
        })
      }
    })
  },
  goToBangDan:function(e){
    var title_id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/index/bangdan/bangdan?bangdanId=' + title_id,
    })
  },
  gotoDetails(e){
    var works_id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/details/details?WorksId=' + works_id,
    })
  },
  catall: function (e) {
    var title_id = e.currentTarget.dataset.id;
    var title = e.currentTarget.dataset.title;
    wx.navigateTo({
      url: '/pages/catall/catall?catallTitle=' + title + '&catallId=' + title_id,
    })
  },
})
